/**
 * @file TcpApp_client_pdu.c
 * @brief TcpApp ADU formatting and parsing
 *
 * @section License
 *
 * SPDX-License-Identifier: GPL-2.0-or-later
 *
 * Copyright (C) 2010-2025 Oryx Embedded SARL. All rights reserved.
 *
 * This file is part of CycloneTCP Open.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 *
 * @author Oryx Embedded SARL (www.oryx-embedded.com)
 * @version 2.5.2
 **/

// Switch to the appropriate trace level
#define TRACE_LEVEL TCP_APP_TRACE_LEVEL

// Dependencies
#include "client/tcp_client_app.h"
#include "client/tcp_client_app_pdu.h"
#include "client/tcp_client_app_misc.h"

/**
 * @brief Format Read Registers request
 * @param[in] context Pointer to the TcpApp/TCP client context
 * @param[in] address Starting register address
 * @param[in] quantity Number of registers
 * @return Error code
 **/

error_t TcpAppClientSendDataExec(TcpAppClientContext *context, const uint8_t *data, size_t length)
{
   // data package
   memcpy(context->requestAdu, data, length);
   context->requestAduLen = length;

   // Rewind to the beginning of the transmit buffer
   context->requestAduPos = 0;
   // Save current time
   context->timestamp = osGetSystemTime();
   // Send the request ADU to the server
   context->state = TCP_APP_CLIENT_STATE_SENDING;

   // Successful processing
   return NO_ERROR;
}

/**
 * @brief Parse Read Holding Registers response
 * @param[in] context Pointer to the TcpApp/TCP client context
 * @return Error code
 **/

error_t TcpAppClientSendDataResp(TcpAppClientContext *context)
{
   // prehandle

   // Successful processing
   return NO_ERROR;
}
